# -*- coding:utf-8 -*-

class Bonus:
    def getMost(self, board):
        # write code here
        m, n = len(board), len(board[0])
        dp = [[0] * (n + 1) for _ in range(m + 1)]
        for i in range(1, m + 1):
            for j in range(1, n + 1):
                dp[i][j] = max(
                    dp[i - 1][j],
                    dp[i][j - 1]
                ) + board[i - 1][j - 1]
        return dp[-1][-1]


if __name__ == '__main__':
    s = Bonus()
    print(s.getMost([[426, 306, 641, 372, 477, 409], [223, 172, 327, 586, 363, 553], [292, 645, 248, 316, 711, 295],
                     [127, 192, 495, 208, 547, 175], [131, 448, 178, 264, 207, 676], [655, 407, 309, 358, 246, 714]]))

"""
[[426,306,641,372,477,409],[223,172,327,586,363,553],[292,645,248,316,711,295],[127,192,495,208,547,175],[131,448,178,264,207,676],[655,407,309,358,246,714]]
[[138,457,411,440,433,149],[203,288,318,597,246,686],[442,105,424,544,406,532],[172,592,626,410,511,636],[394,596,644,454,343,389],[573,460,307,221,325,104]]
[[564,448,654,186,490,699],[487,444,563,228,365,261],[429,505,612,564,715,726],[464,617,234,647,702,263],[245,249,231,462,453,646],[669,510,492,512,622,135]]
[[709,696,666,566,155,624],[625,115,676,572,383,168],[300,232,254,350,660,226],[582,520,436,205,115,153],[569,415,524,388,165,551],[359,426,274,505,457,478]]
[[171,390,403,161,626,500],[650,646,698,221,528,523],[189,398,640,511,369,654],[654,220,427,443,250,523],[179,653,452,477,302,605],[268,432,310,107,674,507]]
[[298,372,461,313,258,678],[220,317,511,574,159,494],[596,459,240,189,661,727],[665,722,212,200,516,687],[152,704,666,291,561,252],[721,152,698,545,254,398]]
[[365,451,550,457,290,609],[674,167,562,714,429,158],[264,372,390,724,265,112],[376,719,121,598,308,579],[139,261,584,495,639,642],[692,130,726,705,371,148]]
[[696,231,164,592,557,391],[701,106,497,701,270,266],[448,327,169,458,155,295],[695,538,247,274,360,132],[254,555,571,314,222,520],[297,579,345,319,509,419]]
[[380,340,442,551,149,520],[471,264,130,570,622,524],[191,708,479,420,142,171],[554,377,649,496,526,438],[342,362,587,366,369,525],[699,274,394,285,295,705]]
[[172,485,633,361,578,405],[504,648,140,206,521,302],[163,612,254,348,624,175],[502,630,305,175,353,635],[189,619,630,721,687,259],[113,652,336,304,406,669]]
[[593,724,171,204,388,105],[225,253,410,475,481,124],[235,520,691,376,524,145],[445,167,510,561,595,685],[361,458,376,226,414,240],[562,209,579,175,256,407]]
[[169,555,366,271,483,549],[635,191,399,521,579,476],[590,199,279,347,137,504],[368,313,723,124,351,710],[427,188,507,578,668,228],[312,236,299,276,151,246]]
[[306,295,500,693,721,532],[486,657,708,300,215,648],[367,349,699,684,476,376],[669,683,458,360,631,464]
"""
